<template>
    <div>
        <a-modal v-model="show" title="添加组织" @ok="submit" @cancel="show = false">
            <a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 19 }">
                <a-form-item label="组织名称">
                    <a-input v-model="orgName" />
                </a-form-item>
            </a-form>
        </a-modal>
    </div>
</template>
<script>
    import { message } from 'ant-design-vue';
    import { addOrg } from "@/services/v2"
    export default {
        props: {

        },
        data() {
            return {
                // 是否显示弹框
                show: false,
                orgName: '',
            }
        },
        methods: {

            //打开弹窗,初始化
            open() {
                this.show = true
            },

            //编辑提交
            submit: function () {
                let self = this;
                addOrg(self.orgName).then((ref) => {
                    if (ref.code != 0) {
                        return message.warning(ref.msg);
                    }
                    message.success('添加成功', 2, function () {
                        self.show = false; //关闭编辑组件
                        self.$emit('ok', 1);//通知父级
                    });
                });
            }
        },
    }
</script>